package com.wangcang.widgetlibrary.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.wangcang.widgetlibrary.R;

public class ButtonActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView mButtonActivityBtnNoclick;
    private Button mBtnState;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo_activity_buton);
        initView();
    }

    private void initView() {
        mButtonActivityBtnNoclick = (TextView) findViewById(R.id.button_activity_btn_noclick);
        mBtnState = (Button) findViewById(R.id.btn_state);
        mBtnState.setOnClickListener(this);
        mButtonActivityBtnNoclick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mButtonActivityBtnNoclick.isSelected()){
                    mButtonActivityBtnNoclick.setSelected(!mButtonActivityBtnNoclick.isSelected());
                }else{
                    mButtonActivityBtnNoclick.setSelected(!mButtonActivityBtnNoclick.isSelected());
                }
            }
        });
    }

    @Override
    public void onClick(View v) {
        if(mBtnState.isSelected()){
            mBtnState.setSelected(!mBtnState.isSelected());
        }else{
            mBtnState.setSelected(!mBtnState.isSelected());
        }
    }
}
